#include <QGraphicsScene>
#include<QGraphicsView>
#include<QIcon>
#include <QApplication>
#include"GameSetting.h"
#include"player.h"
#include"score.h"
#include"health.h"
#include<QtMultimedia>
#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

  
    a.setApplicationDisplayName("芙芙与膨膨兽");
    QApplication::setWindowIcon(QIcon(":/images/Player-removebg-preview.png"));
    //创建player
    Player* player = new Player;

    //创建场景
    QGraphicsScene* scene = new QGraphicsScene;
    scene->addItem(player);
    scene->setSceneRect(0,0,GameSetting::SceneWidth,
                        GameSetting::SceneHeight);
    scene->setBackgroundBrush(QImage(":/images/background.png"));

    //创建分数文字item
    scene->addItem(&Score::getInstance());

    //创建生命值文字
    scene->addItem(&Health::getInstance());
    scene->setStickyFocus(true);//不会在点击时，取消聚焦

    QGraphicsView view(scene);
    view.setFixedSize(GameSetting::SceneWidth,
                      GameSetting::SceneHeight);
    view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view.show();

    //添加背景音乐
    QMediaPlayer bgMusic;
    QAudioOutput audioOutput;
    bgMusic.setAudioOutput(&audioOutput);
    bgMusic.setSource(QUrl("qrc:/music/bgm.ogg"));
    bgMusic.play();


    return a.exec();
}
